package com.tul.exercise.base.java8.stream.flatMap;

import com.tul.exercise.base.java8.stream.base.Artist;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Stream 的flat Map方法
 * @author tuliang
 */
public class FlatMapTest {
    @Test
    @DisplayName("flatMap()方法")
    public void test01(){
        List<Artist> p = Artist.createArtists(9);

        List<Artist> artists = Stream.of(Arrays.asList(p.get(0), p.get(1)),
                Arrays.asList(p.get(2),p.get(3)))
                .flatMap(list -> list.stream()).collect(Collectors.toList());
        System.out.println(artists.size() + ":" + artists);

    }
}
